package zhh.tangbao.machine.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zhh.tangbao.machine.dto.PickUpDto;
import zhh.tangbao.machine.dto.TicketCheckDto;
import zhh.tangbao.machine.service.MachineConnectService;
import zhh.tangbao.system.result.Result;

/**
 * <p>
 *     负责与模拟硬件进行信号交流的接口
 * </p>
 * @author 粥灰灰
 * <p>2023/3/25</p>
 */

@RestController
@RequestMapping("/connection")
public class MachineConnectController {


    @Autowired
    private MachineConnectService service;

    @PostMapping("/open")
    public Result open(String code) {
        return Result.success().put(service.open(code));
    }

    @PostMapping("/checkTicket")
    public Result checkTicket(@RequestBody TicketCheckDto dto) {
        return Result.success().put(service.checkTicket(dto));
    }

    /**
     * 机器在取货完毕后的回调，更新该部分的取货状态
     */
    @PostMapping("/pickUp")
    public Result pickUp(PickUpDto dto) {
        service.pickUp(dto);
        return Result.success();
    }


}
